const errorDictionary = require('../errorDictionary');
exports.formatResponse = function (req, res, next) {
    res.res = resFn.bind(res);
    res.rej = rejFn.bind(res);
    next();
};
function resFn(data) {
    let res = this;
    res.json({code: 0, result: data || {}});
}
function rejFn(data) {
    console.log(data);
    let res = this;
    res.json({
        code: data.code || 1,
        message: errorDictionary[data.code || 1],
        errorInfo: data.errorInfo || data.message || errorDictionary[data.code || 1],
        result: {}
    });
}
